<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml"
      xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8"/>
    <title>Title</title>
</head>
<body>

<!--/*@thymesVar id="appId" type="java"*/-->
<input type="text" value="" th:value="${appId}" />
<!--/*@thymesVar id="wx_config_wxAppId" type="java"*/-->
<input type="text" value="" th:value="${wx_config_wxAppId}"/>

<script src="/static/js/jquery-1.12.1.min.js" th:src="@{/static/js/jquery-1.12.1.min.js}"/>
<script src="https://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>

<script th:inline="javascript">
    wx.config({
        debug: true,
        appId: /*[[${wx_config_wxAppId}]]*/'',
        timestamp: /*[[${wx_config_timeStamp}]]*/'',
        nonceStr: /*[[${wx_config_nonceStr}]]*/'',
        signature: /*[[${wx_config_signature}]]*/'',
        jsApiList: [
            'checkJsApi',
            'onMenuShareTimeline',
            'onMenuShareAppMessage',
            'onMenuShareQQ',
            'onMenuShareWeibo'
        ]
    });

    function onBridgeReady() {
        WeixinJSBridge.invoke(
                'getBrandWCPayRequest', {
                    "debug": true,
                    "appId": /*[[${appId}]]*/'[[${appId}]]',     //公众号名称，由商户传入
                    "timeStamp": /*[[${timeStamp}]]*/'',         //时间戳，自1970年以来的秒数
                    "nonceStr": /*[[${nonceStr}]]*/'', //随机串
                    "package": /*[[${package}]]*/'',
                    "signType": /*[[${signType}]]*/'',         //微信签名方式:
                    "paySign": /*[[${paySign}]]*/'' //微信签名
                },
                function (res) {
                    if (res.err_msg == "get_brand_wcpay_request:ok") {
                        window.location.href = "/peking/pay/success?callId="+/*[[${callId}]]*/'';
                    }     // 使用以上方式判断前端返回,微信团队郑重提示:res.err_msg将在用户支付成功后返回    ok，但并不保证它绝对可靠。
                }
        )
        ;
    }
    if (typeof WeixinJSBridge == "undefined") {
        if (document.addEventListener) {
            document.addEventListener('WeixinJSBridgeReady', onBridgeReady, false);
        } else if (document.attachEvent) {
            document.attachEvent('WeixinJSBridgeReady', onBridgeReady);
            document.attachEvent('onWeixinJSBridgeReady', onBridgeReady);
        }
    } else {
        onBridgeReady();
    }


</script>

</body>
</html>